﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using weixin.Models;

namespace weixin.Services
{
    public class WeixinMpsService
    {
        private readonly weixin.Models.WeixinOpenPlatEntities db = new Models.WeixinOpenPlatEntities();

        public List<tb_WeixinMps> Query()
        {
            return db.tb_WeixinMps.ToList();
        }

        public tb_WeixinMps GetByAppId(string appid)
        {
            return db.tb_WeixinMps.FirstOrDefault(r => r.appid == appid);
        }

        public bool AddOrUpdate(tb_WeixinMps model)
        {
            if (model.id > 0)
            {
                db.Entry<tb_WeixinMps>(model).State = System.Data.EntityState.Modified;
            }
            else
            {
                db.Entry<tb_WeixinMps>(model).State = System.Data.EntityState.Added;
            }
            return db.SaveChanges() > 0;
        }
    }
}